<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Page for privileged user</title>
    </h:head>
    <h:body>
        Welcome in your page, you can change the number of gnomes in the storehouse
        <br />
        <c:choose>
            <c:when test="#{userManager.client.grade == 1 || userManager.client.grade == 0}">
                <h:link outcome="/userRight.xhtml" value="Manage User">
                    <f:param name="cid" value="#{userManager.conversation.id}"/>
                </h:link>
            </c:when>
        </c:choose>
        <br />
        <br />
        <c:forEach var="gnome" items="#{privilegedMarketManager.listOfAllGnome}">
            <h:form style="border-style: groove ; margin-bottom: 10px ; width: 50%">
                <h:outputLabel for="amountGnome#{gnome.gnomeType}" value="Gnome type : #{gnome.gnomeType}"/>
                <br />
                <br />
                <h:outputLabel value="Number of available gnomes: "/>
                <h:outputText value="#{gnome.numberOfGnomeAvailable}"/>
                <br />
                <h:outputLabel value="How many gnomes do you have? "/>
                <h:inputText value="#{privilegedMarketManager.newNbrOfGnomeInTheStorehouse}"/>
                <br />
                <h:commandButton value="change the storehouse stock" action="#{privilegedMarketManager.changedStrorehouseStock(gnome.gnomeType)}"/>
                <br />
                <br />
                <h:commandButton value="delete item" action="#{privilegedMarketManager.deleteGnomeTypeInTheStorehouse(gnome.gnomeType)}"/>
                <br />
                <br />
            </h:form>
        </c:forEach>   

        <h:form>
            <h:outputLabel value="New gnome type :"/>
            <h:inputText value="#{privilegedMarketManager.newGnomeType}"/> 
            <br />
            <br />
            <h:outputLabel value="Number of available gnomes: "/>
            <h:inputText value="#{privilegedMarketManager.nbrNewGnomeAvailable}"/>
            <br />
            <h:outputLabel value="price? "/>
            <h:inputText value="#{privilegedMarketManager.newGnomePrice}"/>
            <br />
            <h:commandButton value="add a new type of gnome" action="#{privilegedMarketManager.addANewTypeOfGnomeInTheStorehouse()}"/>
            <br />
            <br />
        </h:form>
        <h:link outcome="/market.xhtml" value="Back to the market">
            <f:param name="cid" value="#{userManager.conversation.id}"/>
        </h:link>

    </h:body>
</html>

